|
|
|
|
|
|
|
Dim intAnswer As Integer
'
strObject = dtaUserID.Recordset!object
intAnswer = MsgBox("Delete [" & strObject & "] from User Access?",
vbQuestion + vbYesNo, "Delete Object")
If intAnswer = vbYes Then
dtaUserID.Recordset.Delete
accLoadLists
End If
'
End Sub |
|
|
|
|
|
|
|
|
The routine first asks for confirmation before deleting the object from the list. |
|
|
|
|
|
|
|
|
Now you tackle a tougher one. The subroutine called accDelAll removes all the existing rights objects for the current user. Add the code in Listing 21.26. |
|
|
|
|
|
|
|
|
Listing 21.26. Deleting all existing rights objects with accDelAll. |
|
|
|
|
|
|
|
|
Public Sub accDelAll()
'
' delete all objects from user list
'
Dim strUserID As String
Dim intAnswer As Integer
Dim strSQL As String
Dim ws As Workspace
Dim db As Database
'
' init vars
strUserID = lblUserID
strSQL = "DELETE FROM secAccess WHERE UserID='" & strUserID & "'"
'
' confirm delete
intAnswer = MsgBox("Delete ALL objects for UserID [" & strUserID & "]?",
vbQuestion + vbYesNo, "Erase All")
If intAnswer = vbYes Then
Set ws = DBEngine.CreateWorkspace("usrDelAll", "admin", "")
Set db = ws.OpenDatabase(strDBName)
'
On Error Resume Next
ws.BeginTrans
db.Execute strSQL
If Err.Number = 0 Then
ws.CommitTrans
Else
ws.Rollback
MsgBox "Unable to complete transaction", vbExclamation, "Erase All"
End If
' |
|
|
|
|
|